feat(content-docs): allow autogenerated ID as fallback alias for explicit ID#11769
Open
fresh3nough wants to merge 1 commit intofacebook:mainfrom
Open
feat(content-docs): allow autogenerated ID as fallback alias for explicit ID#11769fresh3nough wants to merge 1 commit intofacebook:mainfrom
fresh3nough wants to merge 1 commit intofacebook:mainfrom
Conversation
…icit ID When a doc has an explicit front matter id that differs from the file-path-based id, the autogenerated id is now preserved as a fallback alias. This means references using the file-path-based id still resolve to the correct document even after an explicit id is assigned. Changes: - Added autoGeneratedId field to DocMetadataBase type - Computed autoGeneratedId in doProcessDocMetadata when front matter id differs from the file name - Updated createDocsByIdIndex to register autogenerated IDs as fallback entries that never override explicit IDs - Added unit tests for autoGeneratedId computation and index aliasing - Updated 5 snapshots to reflect the new field on affected docs (AI-assisted)
✅ [V2]Built without sensitive environment variables
To edit notification comments on pull requests, go to your Netlify project configuration. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Motivation
Closes #11691
When a document uses an explicit
idin front matter, the autogenerated ID (derived from the file path) is completely replaced. This means any existing references that used the file-path-based ID break silently.This PR proposes that the autogenerated ID be preserved as a fallback alias, so both the explicit ID and the file-path-based ID resolve to the same document.
Changes
autoGeneratedIdfield toDocMetadataBasedoProcessDocMetadata, the file-path-based ID is computed and stored when the front matteriddiffers from the file namecreateDocsByIdIndexnow registers autogenerated IDs as fallback entries (never overriding an explicit ID)autoGeneratedIdcomputation andcreateDocsByIdIndexalias behaviorTest Plan
Ran the plugin test suite (
docs.test.ts,index.test.ts,props.test.ts) - all 73 tests pass.New tests cover:
autoGeneratedIdautoGeneratedIdautoGeneratedIdcreateDocsByIdIndexindexes by explicit IDcreateDocsByIdIndexindexes byautoGeneratedIdas fallback aliasautoGeneratedIdalias never overrides an existing explicit ID(AI-assisted)